package com.gosophia.metadataEngine.service;

import java.util.List;
import java.util.Map;

import com.gosophia.commons.OrderCondition;
import com.gosophia.commons.Page;
import com.gosophia.commons.PropertyFilter;
import com.gosophia.commons.exception.BusinessException;

/**
 * 系统业务数据api
 * 
 * @author wangxinbing
 * @since 2011-4-29
 */
public interface BusinessDataService {
    /**
     * 根据系统数据编号，查询该系统数据的详细页面显示信息
     * @param id:要查询的数据在接入的系统表中的id
     * @param metaDataTableId：系统表对应的元数据id
     * @return：Map<String,Object>
     */
    public Map<String,Object> findSystemDataDetail(Long id,Long metaDataTableId);
    
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~wangxinbing 2011-4-29~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /**
     * 手动初始化sessionFactories
     */
	public void initMetadataSessionFactories();
	
	
	/**
     * 分页模糊搜索，查询指定委办局系统表的数据
     * @param metaDataTableId metaDataTableId:指定系统在元数据表中id
     * @param page不能为null page.pageSize>0,page.pageNo>0
     * @param searchString 查询条件
     * @param orderConditions 排序字段列表
     * @parma propertyFilters 
     * @since 2011-4-29
     * @author wangxinbing
     * @return
     */
    public Page<Map<String, Object>> findSystemDataSimpleByPage(Long metaDataTableId,
    		             Page<Map<String, Object>> page,String searchString,List<OrderCondition> orderConditions,List<PropertyFilter> propertyFilters);
    
    /**
     * 分页模糊搜索，查询指定委办局系统表的数据
     * @param metaDataTableId metaDataTableId:指定系统在元数据表中id
     * @param propertyFilters 查询条件列表
     * @param page不能为null page.pageSize>0,page.pageNo>0
     * @param orderConditions 排序字段列表
     * @since 2011-4-29
     * @author wangxinbing
     * @return
     */
    public Page<Map<String, Object>> findSystemDataAdvanceByPage(Long metaDataTableId,
    		List<PropertyFilter> propertyFilters,Page<Map<String, Object>> page,List<OrderCondition> orderConditions);
    /**
     * 查询指定字段的引用值
     * @param metaDataTableId
     * @param metaDataFieldId
     * @return
     */
	public List<List<Object>> findRefValues(Long metaDataTableId, Long metaDataFieldId)throws BusinessException;
	/**
	 * 根据主键ID删除该条业务数据
	 * @param dataId 业务数据ID
	 * @param metaDataTableId 对应的元数据表ID
	 * @throws BusinessException 
	 * @since 2011-6-2
	 * @author wangxinbing
	 */
	public void deleteSystemDataById(Long dataId,Long metaDataTableId) throws BusinessException;
	/**
	 * 更新指定业务数据
	 * @param dataId
	 * @param metaDataTableId
	 * @param values key是实体属性名，value是对应的值
	 * @throws BusinessException
	 */
	public void updateSystemData(Long dataId,Long metaDataTableId,Map<String ,Object> values) throws BusinessException;
	/**
	 * 添加业务数据
	 * @param metaDataTableId 元数据表id,不能为null
	 * @param values 
	 * @throws BusinessException
	 */
	public void addSystemData(Long metaDataTableId,Map<String ,Object> values) throws BusinessException;
}
